package com.itheima.appserver.excepiton;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor

public class ErroResult {
    private String errorCode;
    private String errorMessage;

    public ErroResult(ErrInfo errInfo) {
        this.errorCode = errInfo.getCode();
        this.errorMessage = errInfo.getMsg();
    }



    public static ErroResult ok(){
        return new ErroResult(ErrInfo.OK);
    }
    public static ErroResult ok(ErrInfo errInfo){
        return new ErroResult(errInfo);
    }
    public static ErroResult fail(){
        return new ErroResult(ErrInfo.error);
    }
    public static ErroResult fail(ErrInfo errInfo){
        return new ErroResult(errInfo);
    }





   /* //未知异常
    public static ErroResult error(){
        return ErroResult.builder().errorCode("100001").errorMessage("未知异常，请稍后重试").build();
    }

    //手机号格式错误
    public static ErroResult phoneError(){
        return ErroResult.builder().errorCode("100002").errorMessage("手机号格式错误").build();
    }
    //验证码未失效
    public static ErroResult codeTimeError(){
        return ErroResult.builder().errorCode("100003").errorMessage("验证码未失效").build();
    }

    //验证码未失效
    public static ErroResult codeTimeOutError(){
        return ErroResult.builder().errorCode("100004").errorMessage("验证码已失效").build();
    }
    //验证码错误
    public static ErroResult codeError(ErrInfo errInfo){
        return ;
    }*/


}
